package com.bruce.demo2.patterns.demo1.creational.demo02.factoryMethod.demo3;

/**
 * @PROJECT_NAME design_patterns
 * @DESCRIPTION 简单工厂模式,用来生产咖啡
 * @AUTHOR CNBruceLee
 * @DATE 2021/7/10 18:19
 */
public class staticCoffeeFactory {
    public static Coffee createCoffee(String type) {
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("对不起你点的咖啡没有了");
        }
        return coffee;
    }
}
